package com.lqjava.tuxiaowang.tuxiaowang.customerapp.app.sdk.pay.beans;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lqjava.tuxiaowang.tuxiaowang.beans.enums.UserTypeEnums;
import lombok.Data;

@Data
public class PayRespBean {
	
	public PayRespBean() {
		super();
	}
	
	public PayRespBean(String body, UserTypeEnums userType) {
		JSONObject parseObject = JSON.parseObject(body);
		
		this.appid = parseObject.getString("appid");
		this.cusid = parseObject.getString("cusid");
		this.chnltrxid = parseObject.getString("chnltrxid");
		this.randomstr = parseObject.getString("randomstr");
		this.reqsn = parseObject.getString("reqsn");
		this.retcode = parseObject.getString("retcode");
		this.sign = parseObject.getString("sign");
		this.trxid = parseObject.getString("trxid");
		this.trxstatus = parseObject.getString("trxstatus");
		this.payinfo = UserTypeEnums.WECHART == userType ? JSON.toJSONString(new PayInfo(parseObject.getString("payinfo"))) : parseObject.getString("payinfo");
	}

	
	private String appid;
	private String cusid;
	private String chnltrxid;
	private String randomstr;
	private String reqsn;
	private String retcode;
	private String sign;
	private String trxid;
	private String trxstatus;
	
	private String payinfo;

}
